<!DOCTYPE html>
<html>
<head>
    <title>grid</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <style>
        .box {
            display: grid;
            width: 640px;
            height: 720px;
            border: 1px solid red;
            grid-template-columns: repeat(auto-fill, 100px);
            grid-template-rows: repeat(auto-fill, 100px);
            justify-content: center;
            align-content: center;
            justify-items: stretch;
            align-items: stretch;
            gap: 10px;
        }

        .item {
            text-align: center;
            border: 1px solid green;
        }
    </style>
</head>
<body>
<div class="box">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
    <div class="item">9</div>
</div>
</body>
</html>